{include file="header.html"}
<script src="/js/ckeditor/ckeditor.js"></script>
<style type="text/css">
.input1{
	float: right;
	margin: -7px 0px 0px -30px;
	display: inline-block;
	width: 65%;
}
.oo{
	padding-left: 12px !important;
}
.form{
	margin-top: 30px !important;
}
.pp{
	display: inline-block;
	line-height: 32px;
	margin-bottom: 0px;
}
.pp span{
	color: red;
}
.span1{
	display: inline-block;
	line-height: 32px;
}
#showadd{
	display: inline-block;
	margin-left: 10px;
	font-size: 13px;
	background: #6FB3E0;
	text-align: center;
	border-radius: 4px;
	height: 30px;
    vertical-align: top;
    line-height: 30px;
    width: 60px;
    color: #fff;
    cursor: pointer;
}
</style>
<div class="page-header">
	<h6>
		优惠劵管理
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			编辑优惠劵
		</small>
	</h6>
</div><!-- /.page-header -->
<div class="row">
<div class="col-xs-12">
	<form class="form-horizontal form" role="form" method="post" action="?app=coupon&act=edit" enctype="multipart/form-data">
		<input type="hidden" id="coupon" name="coupon" value="{$row->id}" class="col-xs-6" />
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="name"> 优惠劵名称 </label>
			<div class="col-sm-10">
				<input type="text" id="name" name="name" value="{$row->name}" class="col-xs-6" />
			</div>
		</div>
		<!-- <div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="postion"> 使用位置 </label>
			<div class="col-sm-10">
				<input type="text" id="postion" name="postion" value="{$row->postion}" class="col-xs-6" />
			</div>
		</div> -->
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="coupon_money"> 面额 </label>
			<div class="col-sm-10">
				<input type="number" id="coupon_money" name="coupon_money" value="{$row->coupon_money}" class="col-xs-6" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="status"> 使用条件 </label>
			<div class="col-sm-10">
				<div class="radio">
					<label>
						<input type="radio" name="min" value="1"  class="ace price2" {if $row->min_price > 0} checked {/if}/>
						<span class="lbl" style="display:inline-block;"> 満 </span>
						<input type="number" id="min_price" name="min_price" value="{$row->min_price}" class="col-xs-2 input1" {if $row->min_price == 0}style='display:none;'{/if}/>
					</label>
				</div>
				<div class="radio">
					<label>
						<input type="radio" name="min" value="0" class="ace price" {if $row->min_price == 0} checked {/if}/>
						<span class="lbl"> 无条件 </span>
					</label>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="begin_time"> 有效时间 </label>
			<div class="col-sm-10">
				<input type="text" id="begin_time" name="begin_time" value="{$row->begin_time|date_format:'%Y-%m-%d'}" class="col-xs-3" /><span class="col-xs-1" style="width:50px;font-weight:600;line-height:38px;">---</span>
				<input type="text" id="end_time" name="end_time" value="{$row->end_time|date_format:'%Y-%m-%d'}" class="col-xs-3" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="quantity"> 发行量 </label>
			<div class="col-sm-10">
				<input type="number" id="quantity" name="quantity" placeholder="增加份数" value="" class="col-xs-2" /><p class="pp">上次发行<span>{$sn}</span>份</p>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="num_per_person"> 每人限领 </label>
			<div class="col-sm-10">
				<input type="number" id="num_per_person" name="num_per_person" value="{$row->num_per_person}" class="col-xs-2" /><span class="span1">张</span>
			</div>
		</div>
			<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="offline_use"> 使用范围 </label>
			<div class="col-sm-10">
				<div class="radio">
					<label>
						<input type="radio" name="offline_use" value="1"  class="ace" {if $row->offline_use == 1} checked {/if} />
						<span class="lbl"> 线下 </span>
					</label>
				</div>
				<div class="radio">
					<label>
						<input type="radio" name="offline_use" value="0" class="ace"  {if $row->offline_use == 0} checked {/if} />
						<span class="lbl"> 通用 </span>
					</label>
				</div>
			</div>
		</div>
		<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right" for="permit_goods"> 是否限制商品使用范围 </label>
			<div class="col-sm-10">
				<select name="permit_goods" onchange="showGoods(this)" id="show">
                        <option value="0" {if $row->permit_goods == 0}selected{/if}>不限制</option>
                        <option value="1" {if $row->permit_goods == 1}selected{/if}>限制</option>
                 </select><span onClick="show()" id="showadd")>继续添加</span>
			</div>
		</div>
		<div class="form-group" id="all_goods">
		<label class="col-sm-2 control-label no-padding-right" for="offline_use"></label>
			<div class="col-sm-10">
				<span id="goods"></span>
				{foreach from = $goods item = rs}
				<div id='{$rs->gid}' style='float:left;position:relative;margin-right:10px;'>
					<input id='' type='hidden' name='goods[]' value="{$rs->gid}">
					<label  style='padding: 5px;margin-right:5px;background: #efefef'>{$rs->gid} :  {$rs->name} </label>
					<input type='image' src='/images/gm/horum_img_delete.png' width='10' height='10' style='position:absolute;right:-0.5px;top:-8.5px;' onclick='javascript:onDel(
                    {$rs->gid});'>
                </div>
                 {/foreach}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" style="text-align:right;" for="status"> 状态 </label>
			<div class="col-sm-10">
				<div class="radio">
					<label>
						<input type="radio" name="status" value="1"  class="ace" {if $row->status == 1} checked {/if}/>
						<span class="lbl"> 正常 </span>
					</label>
				</div>
				<div class="radio">
					<label>
						<input type="radio" name="status" value="0" class="ace" {if $row->status == 0} checked {/if}/>
						<span class="lbl"> 隐藏 </span>
					</label>
				</div>
			</div>
		</div>

		<div class="clearfix form-actions">
			<div class="col-md-offset-3 col-md-9">
				<button class="btn btn-info" type="submit">
					<i class="ace-icon fa fa-check bigger-110"></i>
					提交
				</button>

				&nbsp; &nbsp; &nbsp;
				<button class="btn" type="reset">
					<i class="ace-icon fa fa-undo bigger-110"></i>
					重置
				</button>
			</div>
		</div>
	</form>
</div>
</div>
<script type="text/javascript">
    function showGoods(obj){
        // document.getElementById("extra_url").style.display="none";
        var iWidth=720;                          //弹出窗口的宽度;
        var iHeight=600;                         //弹出窗口的高度;
        var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
        var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
        var features = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+iWidth+",height="+iHeight+",top="+iTop+",left="+iLeft;
        switch(obj.value)
        {
            case "0":
                document.getElementById("goods").style.display="";
                document.getElementById("all_goods").innerHTML="";
                break;
            case "1":
                window.open("?app=goods&act=choose","",features);
                break;
            default:
                break;
        }
    }
    function onDel(id)
    {
        if(confirm("是否删除？")){
            var picdiv = document.getElementById(id);
            picdiv.parentNode.removeChild(picdiv);
            // if(document.getElementById("goods").childNodes.length==0)
            // {
            //      document.getElementById("all_goods").style.display="none";
            // }
        }
    }
</script>
<script type="text/javascript">
	$(function(){
		$('#begin_time').datepicker({
			useStyle:'datepicker2',
			readonly:false,
			showTime:true,
			showSecond:false,
			format:'yyyy-mm-dd hh:mm'
		});
		$('#end_time').datepicker({
			useStyle:'datepicker2',
			readonly:false,
			showTime:true,
			showSecond:false,
			format:'yyyy-mm-dd hh:mm'
		});
		$('.price').click(function(){
			$('.input1').hide();
			$('.input1').val('');
		});
		$('.price2').click(function(){
			$('.input1').show();
		});
		if(!{$row->permit_goods}){
			$('#showadd').hide();
		}
		$('#show').click(function(){
			if($('#show').val() == 1){
				$('#showadd').show();
			}else{
				$('#showadd').hide();
			}
		});
	});
	function show(obj){
        // document.getElementById("extra_url").style.display="none";
        var iWidth=720;                          //弹出窗口的宽度;
        var iHeight=600;                         //弹出窗口的高度;
        var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
        var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
        var features = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+iWidth+",height="+iHeight+",top="+iTop+",left="+iLeft;
     	window.open("?app=goods&act=choose","",features);
    }
</script>

{include file="footer.html"}